package tedu.study.day04;

import java.util.Scanner;

public class Day04Practise {
    public static void main(String[] args) {
        //创建扫描仪
        Scanner scan = new Scanner(System.in);
        //scoreLevel(scan);
        //commandBySwitch(scan);
        //获取随机数1~1000
        int random = (int)(Math.random()*1000+1);
        //guessingWhile(scan,random);
        guessingDoWhile(scan,random);
    }

    public static void scoreLevel(Scanner scan){
        System.out.println("请输入成绩：");
        double score = scan.nextDouble();

        if(score<0 || score>100){
            System.out.println("成绩不合法");
        }else if(score>=90){
            System.out.println("成绩"+score+",评级A-优秀");
        }else if(score>=80){
            System.out.println("成绩"+score+",评级B-良好");
        }else if(score>=60){
            System.out.println("成绩"+score+",评级C-中等");
        }else{
            System.out.println("成绩"+score+",评级D-不合格");
        }

    }

    public static void commandBySwitch(Scanner scan){
        System.out.println("请输入操作命令：1.存钱 2.取钱 3.退卡");
        int command = scan.nextInt();
        System.out.println("输入的命令为："+command);
        switch (command){
            case 1:
                System.out.println("存款业务处理中...");
                break;
            case 2:
                System.out.println("取款业务办理中...");
                break;
            case 3:
                System.out.println("退卡");
                break;
            default:
                System.out.println("输入错误");
        }
    }

    public static void guessingWhile(Scanner scan,int random){
        System.out.println("随机生成的猜测数字是"+random);

        System.out.println("猜吧！");
        int guess = scan.nextInt();//1
        while(guess!=random){//2
            if(guess>random){
                System.out.println("太大了");
            }else{
                System.out.println("太小了");
            }
            System.out.println("猜吧");
            guess = scan.nextInt();//3
        }
        System.out.println("恭喜你猜对了！");
    }

    public static void guessingDoWhile(Scanner scan,int random){
        System.out.println("随机生成的猜测数字是"+random);

        int guess;
        do{
            System.out.println("猜吧！");
            guess=scan.nextInt();//1+3
            if(guess>random){
                System.out.println("太大了");
            }else if(guess<random){
                System.out.println("太小了");
            }else{
                System.out.println("恭喜你猜对了！");
            }
        }while(guess!=random);
    }
}
